Completed
Pull Request — master (#13)
by Justin
07:02
created

not copy instancesꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
var assert = require('chai').assert,
2
    GedcomX = require('../');
3
4
describe('ExtensibleData', function(){
5
  
6
  it('Create plain', function(){
7
    var newEd = new GedcomX.ExtensibleData(),
8
        ed = GedcomX.ExtensibleData();
9
    assert.instanceOf(newEd, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor with new.');
10
    assert.instanceOf(ed, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor without new.');
11
  });
12
  
13
  it('Create with JSON', function(){
14
    var ed = GedcomX.ExtensibleData({ id: 'edid' });
15
    assert.equal(ed.getId(), 'edid', 'ID not saved properly when created with JSON');
16
  });
17
  
18
  it('Change ID', function(){
19
    var ed = GedcomX.ExtensibleData({ id: 'edid' });
20
    ed.setId('newId');
21
    assert.equal(ed.getId(), 'newId', 'ID not saved properly when changed with setId()');
22
  });
23
  
24
  it('toJSON()', function(){
25
    var ed = GedcomX.ExtensibleData({ id: 'firstId' });
26
    ed.setId('newId');
27
    assert.deepEqual(ed.toJSON(), {id:'newId'}, 'JSON export is incorrect');
28
  });
29
  
30
  it('constructor does not copy instances', function(){
31
    var obj1 = GedcomX.ExtensibleData();
32
    var obj2 = GedcomX.ExtensibleData(obj1);
33
    assert.strictEqual(obj1, obj2);
34
  });
35
  
36
});